<template>
  <div ref="echarts" class="my-echarts"></div>
</template>
<script>
import echarts from 'echarts';

export default {
  name: 'echarts',
  props: {
    option: {
      type: Object,
      required: true,
      default: () => ({}),
    },
  },
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.chart = echarts.init(this.$refs.echarts);
      this.setOption(this.option);
    });
  },
  methods: {
    setOption(option) {
      this.chart.setOption(option);
    },
  },
};
</script>
<style lang="scss" scoped>
.my-echarts{
  height: 100%;
}
</style>

